package com.qfedu.zf.index.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.zf.common.vo.R;
import com.qfedu.zf.index.entity.Amenities;
import com.qfedu.zf.index.mapper.AmenitiesMapper;
import com.qfedu.zf.index.service.AmenitiesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 存储房源的设施信息 服务实现类
 * </p>
 *
 * @author wgz
 * @since 2024-06-19
 */
@Service
public class AmenitiesServiceImpl extends ServiceImpl<AmenitiesMapper, Amenities> implements AmenitiesService {

    @Autowired
    AmenitiesMapper amenitiesMapper;

    @Override
    public R listByListingId(Map<String, Object> map) {
        if (map.get("listingId") == null || map.get("listingId") == "") {
            System.out.println("map = " + map);
            return R.fail("参数错误");
        }
        QueryWrapper<Amenities> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("listing_id",Integer.parseInt((String) map.get("listingId")));
        List<Amenities> amenities = amenitiesMapper.selectList(queryWrapper);
        return R.ok(amenities);
    }
}
